﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


/// <summary>
/// set display configuration
/// </summary>
public class AppConfig : MonoBehaviour
{
    float screenRatio_bottom;
    float screenRatio_top;
    public Canvas canvas_bottom;
    public Canvas canvas_top;
    public static AppConfig _instance;

    Vector2 screenSize_bottom;
    // Start is called before the first frame update
    void Awake()
    {
        _instance = this;
        screenRatio_bottom = Display.displays[0].renderingHeight / 1080.0f;
        Debug.Log(screenRatio_bottom);
        screenSize_bottom = new Vector2(Display.displays[0].renderingWidth, Display.displays[0].renderingHeight);

        //display configuration
        Display.displays[0].Activate();

        Display.displays[0].SetRenderingResolution(Screen.width, Screen.height);
        
        if (Display.displays.Length > 1)
        {
            Display.displays[1].Activate();
            
            Display.displays[1].SetRenderingResolution(Screen.width, Screen.height);
            screenRatio_top = Display.displays[1].renderingHeight / 1080.0f;
            Debug.Log(screenRatio_top);
        }
        canvas_bottom.scaleFactor = screenRatio_bottom;
        
        if(canvas_top != null)canvas_top.scaleFactor = screenRatio_top;
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public float GetScreenRatioBottom()
    {
        return (screenRatio_bottom);
    }
}
